<%-- 
    Document   : phoneBookManager.jsp
    Created on : 2010. 12. 5, 오후 12:55:24
    Author     : jeffreyha
--%>

<%@page import="java.net.URLEncoder"%>
<%@page import="java.util.Enumeration"%>
<%@page import="net.hekka.canyoutalk.web.vo.PageVo"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

    <%
        HttpSession httpSession = request.getSession();
        PageVo pageVo = (PageVo) request.getAttribute("pageVo");

        int nowPage = (String) request.getAttribute("nowPage") == null ? 0 : Integer.parseInt((String) request.getAttribute("nowPage"));
        int queryCount = (String) request.getAttribute("queryCount") == null ? 0 : Integer.parseInt((String) request.getAttribute("queryCount"));

        int totalPage = (String) request.getAttribute("totalPage") == null ? 0 : Integer.parseInt((String) request.getAttribute("totalPage"));
        int totalCount = (String) request.getAttribute("totalCount") == null ? 0 : Integer.parseInt((String) request.getAttribute("totalCount"));


        String phoneNumber = (String) request.getParameter("phoneNumber") == null ? "" : (String) request.getParameter("phoneNumber");
        String username = (String) request.getParameter("name") == null ? "" : (String) request.getParameter("name");

    %>
    
<script language ="javascript">

    function addPhoneBook(){
        
        var form = document.phoneBookManagerForm;
        var phoneNumber = form.phoneNumber.value;
        var name = form.name.value;
        var escapePhoneNumber = encodeURIComponent(phoneNumber);
        var escapeName = encodeURIComponent(name);
        
        form.target ="main";
        form.action = "PhoneBookServlet?serviceId=addPhoneBook&phoneNumber="+escapePhoneNumber+"&name="+escapeName+"&nowPage="+form.nowPage.value+"&totalCount="+form.totalCount.value+"&queryCount="+form.totalCount.value;
        form.submit();
    }
    function modifyPhoneBook(){
        var form = document.phoneBookManagerForm;
        var phoneNumber = form.phoneNumber.value;
        var name = form.name.value;
        var escapePhoneNumber = encodeURIComponent(phoneNumber);
        var escapeName = encodeURIComponent(name);

        form.target ="main";
        form.action = "PhoneBookServlet?serviceId=modifyPhoneBook&phoneNumber="+escapePhoneNumber+"&name="+escapeName+"&nowPage="+form.nowPage.value+"&totalCount="+form.totalCount.value+"&queryCount="+form.totalCount.value;
        form.submit();
    }
    function erasePhoneBook(){
        var form = document.phoneBookManagerForm;
        var phoneNumber = form.phoneNumber.value;
        var name = form.name.value;
        var escapePhoneNumber = encodeURIComponent(phoneNumber);
        var escapeName = encodeURIComponent(name);

        form.target ="main";
        form.action = "PhoneBookServlet?serviceId=erasePhoneBook&phoneNumber="+escapePhoneNumber+"&nowPage="+form.nowPage.value+"&totalCount="+form.totalCount.value+"&queryCount="+form.totalCount.value;
        form.submit();
    }

</script>

<html>
    <head>
<!--        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">-->
        <title>phoneBookManager</title>
        <link rel="StyleSheet" type="text/css" href="./css/maincss.css" />
    </head>



    <body>
        <div id="wrapper">

            <div id="content" align="center">

         <FORM id ="phoneBookManagerForm" name="phoneBookManagerForm" method="post" action ="" accept-charset="UTF-8">

             <input type="hidden" name="nowPage" value ='<%=nowPage%>'>
             <input type="hidden" name="queryCount" value ='<%=queryCount%>'>
             <input type="hidden" name="totalPage" value ='<%=totalPage%>'>
             <input type="hidden" name="totalCount" value ='<%=totalCount%>'>

             <table  border="1" cellpadding="0" cellspacing="1" >
                <tr>
                    Phone Book
                </tr>
                <tr>
                    <td nowrap width="60" 	bgcolor = "#336699" align="center"><font color="white"> PhoneNumber </font></td>
                    <td><input size="45" type="text" name="phoneNumber" value="<%=phoneNumber%>" /></td>
                </tr>
                <tr>
                    <td nowrap width="60" 	bgcolor = "#336699" align="center"><font color="white"> Name </font></td>
                    <td><input size="45" type="text" name="name" value="<%=username%>" /></td>
                </tr>
            </table>
             <table  border="0" cellpadding="0" cellspacing="1" >
                 <tr>
                     <td><input type="button" value="add" onclick="addPhoneBook('');" </td>
                    <td><input type="button" value="modify" onclick="modifyPhoneBook('');"  </td>
                    <td><input type="button" value="erase" onclick="erasePhoneBook('');"  </td>
                </tr>
             </table>
         </FORM>
            </div>
        </div>
    </body>
</html>
